import { url } from './url'
import request from './request'
const BMapGL = window.BMapGL;
export const getCity = async () => {
    let currentCity = JSON.parse(window.localStorage.getItem('city'))
    if (!currentCity) {
        function myFun(result) {
            var cityName = result.name;
            currentCity = cityName
        }
        var myCity = new BMapGL.LocalCity();
        myCity.get(myFun);
        const res = await request({
            url: '/area/info',
            type: 'GET'
        })
        currentCity = res.data.body
        window.localStorage.setItem('city', JSON.stringify(res.data.body))
    }
    return currentCity
}
export const setCity = (obj) => {
    window.localStorage.setItem('city', JSON.stringify(obj))
}
export const setToken = (value) => {
    window.localStorage.setItem('token', value)
}
export const getToken = (value) => {
    return window.localStorage.getItem('token')
}
export const isAu = () => {
    return !!window.localStorage.getItem('token')
}
export { request, url }